home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts28-10
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: NEWBIE : Need help with C++
- Date: Tue, 12 Mar 96 03:53:14 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4i2sfr$nfn@sam.inforamp.net>
- References: <Pine.SOL.3.91.960310214829.26563A-100000@orion>
- NNTP-Posting-Host: ts28-10.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <Pine.SOL.3.91.960310214829.26563A-100000@orion>,
- franco <c2eyf931@Simpang.Raya> wrote:
- >Can someone tell me what a bucket sort is.
-
- Bucket sorting.
- Basically you put the objects in buckets, that is, hash slots that contain
- more then one entry. Thus using your example...
-
- typedef "Some type of container class" Bucket;
-
- main()
- {
- const int arraysize = 5;
- int a[arraysize] = {2, 27, 100, 34, 188};
- Bucket b[10];
- for (int i=0; i<arraysize; i++)
- b[a[i]%10].Add(a[i]);
- };
-
- This sorts the integers in buckets using the unit digit. You have ten buckets
- each representing the ten unit digits. You determine which bucket they belong
- to and toss them in. Sort of like picking apples and you throw Granny Smiths
- in one basket, MacIntoshes in another, overripe in another, bad in another.
-
- I hope this helps.
-
- Agrivar
-